package util;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.util.ResourceBundle;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;

import modelUtil.Util;
import paginas.PaginaEntornoCreacionTeclados;
import AccionBoton.AccionCerrar;
import AccionBoton.AccionGuardarTeclado;
import AccionBoton.AccionVolverVisible;

public class PopUpConfirmarSalida extends JDialog{

	private static final long serialVersionUID = 1L;
	private PaginaEntornoCreacionTeclados _frame;
	
	public PopUpConfirmarSalida(PaginaEntornoCreacionTeclados frame){
		
		_frame = frame;
		initComponents();
		Toolkit tk = Toolkit.getDefaultToolkit();
		Dimension screenSize = tk.getScreenSize();
        //this.setFocusableWindowState(false);
		setBounds((screenSize.width/2)-275, (screenSize.height/2)-100, 550, 200);
		setModal(true);
		setAlwaysOnTop(true);
		setLocationRelativeTo(null);
		this.pack();
		this.repaint();
		setVisible(true);
		
	}
	
	public void initComponents(){
		
		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(550,200));
		GridLayout grid = new GridLayout(2,1);
		TitledBorder border = new TitledBorder(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_titulo_confirmacion_salir"));
		border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD, 14));
		panel.setBorder(border);
		panel.setLayout(grid);
		add(panel);
		JPanel panel1 = new JPanel();
		JPanel panel2 = new JPanel();

		panel1.setPreferredSize(new Dimension(400,100));
		panel2.setPreferredSize(new Dimension(400,100));
		grid.addLayoutComponent("panel1", panel1);
		panel.add(panel1);
		grid.addLayoutComponent("panel2", panel2);
		panel.add(panel2);
		
		FlowLayout lay1 = new FlowLayout();
		lay1.setAlignment(FlowLayout.LEFT);
		panel1.setLayout(lay1);
		FlowLayout lay2 = new FlowLayout();
		lay2.setAlignment(FlowLayout.CENTER);
		panel2.setLayout(lay2);

		
		
		JLabel et = new JLabel(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_texto_confirmacion_salir"));
		et.setFont(et.getFont().deriveFont(Font.BOLD, 14));

		
		lay1.addLayoutComponent("et", et);
		lay1.setAlignment(FlowLayout.CENTER);
		panel1.add(et);
		

		
		BotonPersonalizado b1 = Util.BotonImagen(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_confirmar_si"), "lib//Aceptar.png");
		b1.setPreferredSize(new Dimension(150,40));
		b1.setBackground(new Color(238,238,238));
		b1.getLabelImagen().setHorizontalAlignment(SwingConstants.LEFT);
		b1.getLabelTexto().setHorizontalAlignment(SwingConstants.RIGHT);
		b1.addActionListener(new AccionGuardarTeclado(_frame,this));
		b1.addActionListener(new AccionVolverVisible(_frame.get_frame()));

		BotonPersonalizado b2 = Util.BotonImagen(ResourceBundle.getBundle("internacionalizacion/Etiquetas").getString("etiqueta_confirmar_no"), "lib//cancelar.png");
		b2.getLabelImagen().setHorizontalAlignment(SwingConstants.LEFT);
		b2.setBackground(new Color(238,238,238));
		b2.getLabelTexto().setHorizontalAlignment(SwingConstants.RIGHT);
		b2.setPreferredSize(new Dimension(150,40));
		b2.addActionListener(new AccionVolverVisible(_frame.get_frame()));
		b2.addActionListener(new AccionCerrar(_frame));
		b2.addActionListener(new AccionCerrar(this));
		
		lay2.addLayoutComponent("b1", b1);
		panel2.add(b1);
		
		lay2.addLayoutComponent("b2", b2);
		panel2.add(b2);
		


		
		
	}
	
}
